import java.io.IOException;
import java.util.Properties;

import br.ufmg.vod.wbr.algorithims.dfs.FastDFS;
import br.ufmg.vod.wbr.graphs.DirectedToUndirected;
import br.ufmg.vod.wbr.graphs.FastDirectedGraph;
import br.ufmg.vod.wbr.graphs.FastGraph;
import br.ufmg.vod.wbr.graphs.IDXGraphLoader;


public class MyDFS {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		Properties props = new Properties(); 
		props.load(ClassLoader.getSystemResourceAsStream("collection.properties"));
		String inLinkIdx = props.getProperty("collection.path")+props.getProperty("inlinks.idx");
		String inLink = props.getProperty("collection.path")+props.getProperty("inlinks");
		String outLinkIdx = props.getProperty("collection.path")+props.getProperty("outlinks.idx");
		String outLink = props.getProperty("collection.path")+props.getProperty("outlinks");
		boolean sample = Boolean.valueOf(props.getProperty("sample"));
		int sampleSize = Integer.valueOf(props.getProperty("sample.size"));
		System.out.println(props);
		
		
		long start = System.currentTimeMillis();
		FastDirectedGraph directedGraph = new IDXGraphLoader(inLinkIdx, inLink, outLinkIdx, outLink, sample, sampleSize).loadGraph();
		FastGraph undirectedGraph = new DirectedToUndirected(directedGraph).loadGraph();
		System.err.printf("GraphContructor: %.3f seconds.\n",(System.currentTimeMillis()-start)/1000f);
		
		FastDFS algorithm = new FastDFS(directedGraph);
		algorithm.run();
		System.err.printf("FastDFS(directedGraph): %.3f seconds.\n",(System.currentTimeMillis()-start)/1000f);
		
		algorithm = new FastDFS(undirectedGraph);
		algorithm.run();
		System.err.printf("FastDFS(undirectedGraph): %.3f seconds.\n",(System.currentTimeMillis()-start)/1000f);
	}

}
